﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ivony.Data;
using XCommunity.Frames;

namespace XCommunity.Data
{
  public class TopicFrameDataProvider
  {

    public static readonly SqlDbUtility DbUtility = new SqlDbUtility( @"Data Source=(local);Initial Catalog=XCommunity;Integrated Security=True" );

    public int CreateThread( string title )
    {
      return Convert.ToInt32( DbUtility.ExecuteScalar( "INSERT INTO Topics ( Title ) VALUES ( {0} ); SELECT @@Identity", title ) );
    }

    public void PublishDocument( int topicId, int documentId, string method )
    {
      DbUtility.ExecuteNonQuery( "INSERT INTO PublishedDocuments ( TopicId, DocumentId, PublishMethod, PublishDate ) VALUES ( {...} );", topicId, documentId, method, DateTime.UtcNow );
    }



    public void ModifyTitle( int topicId, string title )
    {
      DbUtility.ExecuteNonQuery( "UPDATE Topics SET Title = {1} WHERE ID = {0}", topicId, title );
    }
  }
}
